
package com.insigma.business.qrcode.soldier.request;

import com.google.common.base.Strings;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import com.insigma.business.qrcode.soldier.util.DateUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;


@Getter
@Setter
public class CommonLedgerStatsRequest implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer pageNo = 1;

    private Integer pageSize = 20;

    
    private String adminAreaCode;

    
    private Date startTime;

    
    private Date endTime;

    
    private String statsTime;

    public boolean convertTime() {
        if (Strings.isNullOrEmpty(statsTime)) {
            return true;
        }

        List<Date> list = DateUtils.intersectionTime(statsTime, startTime, endTime);
        if (CollectionUtils.isEmpty(list)) {
            startTime = null;
            endTime = null;
            return false;
        } else {
            startTime = list.get(0);
            endTime = list.get(1);
            return true;
        }
    }
}
